package com.hssoftvn.android.apps.callmessmoneycontroller.util;

import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
import android.content.Context;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.widget.Toast;

import com.hssoftvn.android.apps.callmessmoneycontroller.MainActivity;
import com.hssoftvn.android.apps.callmessmoneycontroller.enums.DialogConstansts;

public class SUtils {
	
	public final static String TAG = "CallMessMoneyCont";
	
	static MainActivity gApplicationInstance=null;
	static Toast gToast = null;
	static AlertDialog gDialog= null;
	
	public static void init(Context context){
		gApplicationInstance = (MainActivity) context;

	}
	public static MainActivity getAppContext(){
		return gApplicationInstance;
	}
	
	public static void showToastMessage(final String message){
		SUtils.getAppContext().runOnUiThread(new Runnable() {			
			@Override
			public void run() {
				// TODO Auto-generated method stub
				if (gToast == null){
					gToast = Toast.makeText(getAppContext(), message, Toast.LENGTH_LONG);
				}
				gToast.setText("");
				gToast.show();
				gToast.setText(message);
				gToast.setDuration(Toast.LENGTH_LONG);
				gToast.show();
			}
		});
	}
	public static void showDialogMessage(final String title, final String message, DialogConstansts buttons){		
	}
	public static void showDialogMessage(final String title, final String message){
		SUtils.getAppContext().runOnUiThread(new Runnable() {
			@Override
			public void run() {
				// TODO Auto-generated method stub
				AlertDialog.Builder builder = new Builder(getAppContext());
				builder.setTitle(title);
				builder.setMessage(message);
				builder.setIcon(com.hssoftvn.android.apps.callmessmoneycontroller.R.drawable.ic_launcher);
				builder.setCancelable(false);
				builder.setPositiveButton("Yes", new OnClickListener() {
					
					@Override
					public void onClick(DialogInterface dialog, int which) {
						// TODO Auto-generated method stub
						dialog.dismiss();
					}
				});
				builder.setNegativeButton("No", new OnClickListener() {
					
					@Override
					public void onClick(DialogInterface dialog, int which) {
						// TODO Auto-generated method stub
						dialog.dismiss();
					}
				});
				builder.setNeutralButton("Ok", new OnClickListener() {
					
					@Override
					public void onClick(DialogInterface dialog, int which) {
						// TODO Auto-generated method stub
						dialog.dismiss();
					}
				});
				
				gDialog = builder.create();				
				gDialog.show();
			}
		});
		//thread.start();
	}
}
